<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{$activityname}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/love/love.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <style>
        html,body{height:100%;}
        .norecord{
            height:504px;
            width:100%;
            text-align:center;
            background-image:url({$Think.config.RESOURCEURL}wx_assets/love/img/noGifts.png{$Think.config.RESOURCE_VER});
            background-position:center top;
            background-size:320px auto;
            background-repeat: no-repeat;
        }
    </style>
</head>
<body>
<div class="receiptor-list" id="PAIHANG"> 
</div>
<script type="text/html" id="tpl">
    <%if(list){
        for(var i=0;i<list.length;i++){
            var item=list[i];
            if(item.createTime){
                item.createTime=item.createTime.replace(/-/g,"/");
            }
        %>
        <div class="box" onclick="paihangbang.toDetail(<%=item.id%>)">
            <div class="recei">
                <%if(item.receiptorUserName){%>
                    <div class="headimgurl">
                        <img src="<%=item.headimgurl1%>">
                    </div>
                    <div class="nickname">
                        <%=item.nickname1%>
                    </div>
                <%} else {%>
                    <div class="headimgurl">
                        <img src="<%=item.picUrl%>">
                    </div>
                    <div class="nickname">
                        未领取
                    </div>
                <%}%>
            </div>
            <div class="time"><%=dateFormat(item.createTime,"yyyy-MM-dd")%></div>
        </div>
        <%}%>
    <%} else {%>
        <div class="norecord"></div>
    <%}%>
</script>
<script>
var baseUrl = '{$Think.config.SERVER_HOST}';
var basePath = 'call.json?customerId={$customerId}&userName={$userName}';
var shareUrl="";
var paihangbang={
    pageSize:50,
    page:0,
    init:function(){
        var me=this;
        this._initEvent();
        $.util.pageLoading.show();
        me._loadList(me.page,function(){
            $.util.pageLoading.hide();
        });
    },
    toDetail:function(id){
        var p=$.util.getParamAsObject();
        var params={
            "regId":id,
            "actId":"{$actId}",
            "miUId":p.miUId,
            "qId":p.qId
        }
        params=encodeURIComponent(JSON.stringify(params));
        location.href= 'call.html?customerId={$customerId}&module=love&method=view&params='+params;
    },
    _initEvent:function(){
        var me=this;
        $.util.initDataLoading({
            me:paihangbang,
            lastChildren:function(){
                return $("#PAIHANG .box:last");
            },
            page:function(){
                return paihangbang.page; 
            },
            pageCount:function(){
                return paihangbang.pageCount;
            }
        });
    },
    _renderList:function(data,page,callback){
       var me=this;
       if(data){
            var html=template("tpl", data),
                container=$("#PAIHANG");
            container.append(html);
            me.page=page;
            me.pageCount=data.pageCount;
            callback && callback();
       }   
    },
    _loadList:function(page,callback){
        var me=this;
        $.req.get("call.json?module=love&customerId={$customerId}&method=lovelist",{
            userName:"{$userName}",
            params:{
                "actId":"{$actId}",
                "start":page,
                "limit":me.pageSize
            }
        },function(data){
            if(data){
                me._renderList(data,page,callback);
            }
        });
    },
    getShareUrl:function(){
        var p=$.util.getParamAsObject();
        var shareUrl="";
        var params={
            "actId":"{$actId}",
            "qId":p.qId,
            "miUId":p.miUId
        };
        params=encodeURIComponent(JSON.stringify(params));
        shareUrl=baseUrl+'call.html?customerId={$customerId}&module=love&scope=1&method=index&params='+params;
        return shareUrl;
    }
}
paihangbang.init();
shareUrl=paihangbang.getShareUrl();
wx_share.init({
    "title":"{$title}",
    "desc":'{$description}',
    "link":shareUrl,
    "imgUrl":"{$picurl}",
    "pkg":{
        "appId": '{$pkg.appId}',
        "timestamp": {$pkg.timestamp},
        "nonceStr": '{$pkg.nonceStr}',
        "signature": '{$pkg.signature}'
    },
    success:function(config,shareType){
        
    }
 });
</script>
</body>
</html>